<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理器材使用情况</title>
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>



<div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm data-jump-btn"> 查看使用器材具体信息 </button>
</div>

        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm data-add-btn"> 添加器材使用情况 </button>
            <button class="layui-btn layui-btn-sm layui-btn-danger data-update-btn"> 修改器材使用情况 </button>

        </div>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">
            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-xs data-count-sel" lay-event="del">删除</a>
            </script>

        </table>
    </div>
</div>

<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table', 'form', 'tableSelect'], function () {
        var $ = layui.jquery,
            table = layui.table,
            form = layui.form,
            tableSelect = layui.tableSelect;

    });
</script>
<script>
    layui.use(['table', 'form'], function () {
        //开始使用

        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;


        var userInfo = layui.data('userInfo');

        //加载信息
        table.render({
            elem: '#currentTableId',
            url: 'http://localhost:8080/equipment_use/findallequipment_use',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'uid', width: 80, title: '使用表编号'},
                {field: 'eid', width: 120, title: '临床试验表编号'},
                {field: 'meid', width: 80, title: '器材编号'},
                {field: 'mename', width: 140, title: '器材名称'},
                {field: 'did', width: 120, title: '医生编号'},
                {field: 'dname', width: 100, title: '医生姓名'},
                {field: 'pid', width: 90, title: '患者编号'},
                {field: 'pname', width: 140, title: '患者姓名'},
                {field: 'remark', width: 100, title: '备注'},
                {title: '操作', width: 150, templet: '#currentTableBar', fixed: "right", align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
        });

// 监听跳转操作
        $(".data-jump-btn").on("click", function () {

            var index = layer.open({
                title: '全部情况',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/use_all.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

        //删除
        table.on('tool(currentTableFilter)', function (obj) {
            if (obj.event === 'del') {
                var data = obj.data;  //得到修改后的值
                $.ajax({
                    url:'http://localhost:8080/equipment_use/delEquipmentById?uid='+data['uid'],
                    method:'post',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        if(res.code==='0'){
                            parent.closeIframe("删除成功!");
                        }
                        else
                            alert(res['msg']);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("删除失败!");
                    }
                }) ;
                table.reload('currentTableId', {
                }, 'data');
                return false;
            }
        });



        // 监听添加操作
        $(".data-add-btn").on("click", function () {

            var index = layer.open({
                title: '添加器材',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/add_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

        // 监听修改操作
        $(".data-update-btn").on("click", function () {

            var index = layer.open({
                title: '修改器材',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/update_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

            return false;
        });
    });






</script>
</body>
</html>